// Package sys
// @Link  https://github.com/bufanyun/hotgo
// @Copyright  Copyright (c) 2025 HotGo CLI
// @Author  Ms <133814250@qq.com>
// @License  https://github.com/bufanyun/hotgo/blob/master/LICENSE
// @AutoGenerate Version 2.17.8
package sys

import (
	"context"
	"hotgo/api/admin/erpinfo"
	"hotgo/internal/model/input/sysin"
	"hotgo/internal/service"
)

var (
	ErpInfo = cErpInfo{}
)

type cErpInfo struct{}

// List 查看erpInfo列表
func (c *cErpInfo) List(ctx context.Context, req *erpinfo.ListReq) (res *erpinfo.ListRes, err error) {
	list, totalCount, err := service.SysErpInfo().List(ctx, &req.ErpInfoListInp)
	if err != nil {
		return
	}

	if list == nil {
		list = []*sysin.ErpInfoListModel{}
	}

	res = new(erpinfo.ListRes)
	res.List = list
	res.PageRes.Pack(req, totalCount)
	return
}

// Export 导出erpInfo列表
func (c *cErpInfo) Export(ctx context.Context, req *erpinfo.ExportReq) (res *erpinfo.ExportRes, err error) {
	err = service.SysErpInfo().Export(ctx, &req.ErpInfoListInp)
	return
}

// Edit 更新erpInfo
func (c *cErpInfo) Edit(ctx context.Context, req *erpinfo.EditReq) (res *erpinfo.EditRes, err error) {
	err = service.SysErpInfo().Edit(ctx, &req.ErpInfoEditInp)
	return
}

// View 获取指定erpInfo信息
func (c *cErpInfo) View(ctx context.Context, req *erpinfo.ViewReq) (res *erpinfo.ViewRes, err error) {
	data, err := service.SysErpInfo().View(ctx, &req.ErpInfoViewInp)
	if err != nil {
		return
	}

	res = new(erpinfo.ViewRes)
	res.ErpInfoViewModel = data
	return
}

// Delete 删除erpInfo
func (c *cErpInfo) Delete(ctx context.Context, req *erpinfo.DeleteReq) (res *erpinfo.DeleteRes, err error) {
	err = service.SysErpInfo().Delete(ctx, &req.ErpInfoDeleteInp)
	return
}
